import { Component, OnInit } from '@angular/core';
import { ServiceArticleService } from '../service/service-article.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.less']
})
export class HomeComponent implements OnInit {

isShow:boolean = true

  constructor(
    private articleService:ServiceArticleService,
    private router:Router
  ) { }

  ngOnInit(): void {
  }
// 菜单弹起收回函数
  UD(){
    const topBar:any = document.querySelector(".nzTopBar")
    if(!this.isShow){
      topBar.style.top='-6%'
    }
    else{
      topBar.style.top='0'
    }
    this.isShow = !this.isShow
  }
// 读取文章函数--测试中
  getArticle(){ 
    const body:any = document.querySelector('.body')
   this.articleService.getArticle().then(data=>data.text()).then(text => body.innerHTML=text
   )
    // fetch('https://localhost:44322/article/GetArticle').then(data=>data.text()).then(text=>{
    //   console.log(text);
      
    }
// 跳转方法
  goto(address:string){
    this.router.navigate([`/home/${address}`])
    if(address == 'main'){
      setTimeout(() => {
        location.reload();
      }, 200);
    }
  }
  
  }

  

